import {observable, action, computed} from 'mobx';

export default class OdocComsStore {
    /**
     * 流程的一些常用store
     */
    @observable
    workflowStores = {};

    /**
     *  从流程表单上传过来的参数
     */
    urlParams = {};

    /**
     * 组件类型
     */
    @observable
    comType = "";

    @computed get requestParam() {
        const {wfGlobalStore = {}, wfOperateStore = {}} = this.workflowStores;
        const {commonParam = {}} = wfGlobalStore;
        const {markInfo = {}, submitParam = {}} = wfOperateStore;
        const {workflowid, nodeid, formid, isbill, f_weaver_belongto_userid, f_weaver_belongto_usertype, creater, creatertype} = commonParam;
        const {requestid} = submitParam;

        return {
            requestid,
            workflowid,
            nodeid,
            formid,
            isbill,
            f_weaver_belongto_userid,
            f_weaver_belongto_usertype,
            creater,
            creatertype,
            markInfo
        };
    }

    /**
     * 通用的，给当前store里的属性设置值的方法
     * @param val k-v对象
     */
    @action
    setPropValue(val = {}) {
        Object.assign(this, {...val});
    }

    @action
    resetStore() {
        this.workflowStores = {};
        this.urlParams = "";
        this.title = "";
        this.comType = "";
    }
}